home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers3.zip / 3C503.ASM next >
Assembly Source File  |  1992-03-03  |  20KB  |  641 lines

  1. ;History:426,1
  2. version    equ    5
  3.  
  4.     include    defs.asm
  5.  
  6. ;/* PC/FTP Packet Driver source, conforming to version 1.05 of the spec,
  7. ;*  for the 3-Com 3C503 interface card.
  8. ;*  Robert C Clements, K1BC, 14 February, 1989
  9. ;*  Portions (C) Copyright 1988, 1989 Robert C Clements
  10. ;*
  11. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  12.  
  13. ;   This program is free software; you can redistribute it and/or modify
  14. ;   it under the terms of the GNU General Public License as published by
  15. ;   the Free Software Foundation, version 1.
  16. ;
  17. ;   This program is distributed in the hope that it will be useful,
  18. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;   GNU General Public License for more details.
  21. ;
  22. ;   You should have received a copy of the GNU General Public License
  23. ;   along with this program; if not, write to the Free Software
  24. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. ;* Change history:
  27. ;*  Updated to driver spec version 1.08 Feb. 17, 1989 by Russell Nelson.
  28. ;*  Changes 27 Jul 89 by Bob Clements (/Rcc)
  29. ;*    Added Thick versus Thin Ethernet switch  27 Jul 89 by Bob Clements (/Rcc)
  30. ;*    Added call to memory_test.
  31. ;*    Added rcv_mode logic.  Started, but didn't finish, multicast logic. 
  32. ;*      Fixed get_address to return current, not PROM, address.
  33. ;*      Minor races fixed.
  34.  
  35. comment /
  36. From: "James A. Harvey" <IJAH400@indyvax.iupui.edu>
  37. Subject: Patches for 6.x packet drivers; lockup problem fixed!
  38.  
  39. Now for the best part, the lockup problem fix.  I think this may be one that
  40. I keep hearing about that for most people the machine locks up for a minute
  41. on startup, but then continues.  For me it was worse because it appears that
  42. the "recovery" time is only short on heavily loaded networks.  The lockup is
  43. caused by the "first page for RX" being set improperly in etopen; I finally
  44. figured it out by looking at code from other drivers that used the DS8390
  45. chip.  One must switch to the page 1 command registers first.
  46. /
  47.  
  48.  
  49. code    segment    word public
  50.     assume    cs:code, ds:code
  51.  
  52. ; Stuff specific to the 3-Com 3C503 Ethernet controller board
  53. ; WD version in C by Bob Clements, K1BC, May 1988 for the KA9Q TCP/IP package
  54. ; 3Com version based on WD8003E version in .ASM, also by Bob Clements, dated
  55. ;  19 August 1988.  The WD and 3Com cards both use the National DS8390.
  56.  
  57. ; Symbol prefix "EN" is for Ethernet, National chip
  58. ; Symbol prefix "E33" is for _E_thernet, _3_Com 50_3_
  59. ; Symbol prefix "E33G" is for registers in the Gate array ASIC.
  60.  
  61. ; The E33 registers - For the ASIC on the 3C503 card:
  62. ; Offsets from the board's base address, which can be set by
  63. ; jumpers to be one of the following 8 values (hex):
  64. ;  350, 330, 310, 300, 2E0, 2A0, 280, 250
  65. ; Factory default address is 300H.
  66. ; The card occupies a block of 16 I/O addresses.
  67. ; It also occupies 16 addresses at base+400 through base+40F.
  68. ; These high-addressed registers are in the ASIC.
  69. ; Recall that the normal PC I/O decoding is only 10 bits. The 11'th
  70. ; bit (400H) can be used on the same card for additional registers.
  71. ; This offset requires word, not byte, arithmetic
  72. ; on the DX register for the setport macro. Current SETPORT is OK.
  73.  
  74. ; The card can also be jumpered to have the shared memory disabled
  75. ; or enabled at one of four addresses: C8000, CC000, D8000 or DC000.
  76. ; This version of the driver REQUIRES the shared memory to be 
  77. ; enabled somewhere.
  78. ; The card can be operated using direct I/O instructions or by
  79. ; using the PC's DMA channels instead of the shared memory, but
  80. ; I haven't included the code for those other two methods. 
  81. ; They would be needed in a system where all four possible addresses
  82. ; for the shared memory are in use by other devices.  /Rcc
  83.  
  84. ; Blocks of I/O addresses:
  85.  
  86. E33GA        equ    400h    ; Registers in the gate array.
  87. E33_SAPROM    equ    000h    ; Window on station addr prom (if
  88.                 ; E33G_CNTRL bits 3,2 = 0,1
  89.  
  90. ; These appear at Base+0 through Base+0F when bits 3,2 of
  91. ; E33G_CNTRL are 0,0.
  92.  
  93. EN_OFF        equ    0h
  94.  
  95. ENDCFG_BM8    equ    48h
  96.  
  97.     include    8390.inc
  98.  
  99. ; Registers in the 3-Com custom Gate Array
  100.  
  101. E33G_STARTPG    equ E33GA+00h    ; Start page, must match EN0_STARTPG
  102. E33G_STOPPG    equ E33GA+01h    ; Stop  page, must match EN0_STOPPG
  103. E33G_NBURST    equ E33GA+02h    ; Size of DMA burst before relinquishing bus
  104. E33G_IOBASE    equ E33GA+03h    ; Bit coded: where I/O regs are jumpered.
  105.                 ; (Which you have to know already to read it)
  106. E33G_ROMBASE    equ E33GA+04h    ; Bit coded: Where/whether EEPROM&DPRAM exist
  107. E33G_GACFR    equ E33GA+05h    ; Config/setup bits for the ASIC GA
  108. E33G_CNTRL    equ E33GA+06h    ; Board's main control register
  109. E33G_STATUS    equ E33GA+07h    ; Status on completions.
  110. E33G_IDCFR    equ E33GA+08h    ; Interrupt/DMA config register
  111.                 ; (Which IRQ to assert, DMA chan to use)
  112. E33G_DMAAH    equ E33GA+09h    ; High byte of DMA address reg
  113. E33G_DMAAL    equ E33GA+0ah    ; Low byte of DMA address reg
  114. E33G_VP2    equ E33GA+0bh    ; Vector pointer - for clearing RAM select
  115. E33G_VP1    equ E33GA+0ch    ;  on a system reset, to re-enable EPROM.
  116. E33G_VP0    equ E33GA+0dh    ;  3Com says set this to Ctrl-Alt-Del handler
  117. E33G_FIFOH    equ E33GA+0eh    ; FIFO for programmed I/O data moves ...
  118. E33G_FIFOL    equ E33GA+0fh    ; .. low byte of above.
  119.  
  120. ; Bits in E33G_CNTRL register:
  121.  
  122. ECNTRL_RESET    equ    001h    ; Software reset of the ASIC and 8390
  123. ECNTRL_THIN    equ    002h    ; Onboard thin-net xcvr enable
  124. ECNTRL_SAPROM    equ    004h    ; Map the station address prom
  125. ECNTRL_DBLBFR    equ    020h    ; FIFO configuration bit
  126. ECNTRL_OUTPUT    equ    040h    ; PC-to-3C503 direction if 1
  127. ECNTRL_INPUT    equ    000h    ; PC-to-3C503 direction if 0
  128. ECNTRL_START    equ    080h    ; Start the DMA logic
  129.  
  130. ; Bits in E33G_STATUS register:
  131.  
  132. ESTAT_DPRDY    equ    080h    ; Data port (of FIFO) ready
  133. ESTAT_UFLW    equ    040h    ; Tried to read FIFO when it was empty
  134. ESTAT_OFLW    equ    020h    ; Tried to write FIFO when it was full
  135. ESTAT_DTC    equ    010h    ; Terminal Count from PC bus DMA logic
  136. ESTAT_DIP    equ    008h    ; DMA In Progress
  137.  
  138. ; Bits in E33G_GACFR register:
  139.  
  140. EGACFR_NORM    equ    049h    ; Enable 8K shared mem, no DMA TC int
  141. EGACFR_IRQOFF    equ    0c9h    ; Above, and disable 8390 IRQ line
  142.  
  143. ; Shared memory management parameters
  144.  
  145. SM_TSTART_PG    equ    020h    ; First page of TX buffer
  146. SM_RSTART_PG    equ    026h    ; Starting page of RX ring
  147. SM_RSTOP_PG    equ    040h    ; Last page +1 of RX ring
  148.  
  149. ; End of 3C503 parameter definitions
  150.  
  151. pause_    macro
  152.     jmp    $+2
  153. endm
  154.  
  155. longpause macro
  156.     push    cx
  157.     mov    cx,0
  158.     loop    $
  159.     pop    cx
  160. endm
  161.  
  162. ram_enable    macro
  163.     setport    E33G_GACFR    ; Make sure gate array is set up and
  164.     mov al,    EGACFR_NORM    ;  the RAM is enabled (not EPROM)
  165.     out dx,    al        ; ..
  166.     endm
  167.  
  168.  
  169. reset_8390    macro
  170.     loadport        ; First, pulse the board reset
  171.     setport    E33G_CNTRL
  172.     mov    al,thin_bit        ; Thick or thin cable bit
  173.     or    al,ECNTRL_RESET
  174.     out    dx,al            ; Turn on board reset bit
  175.     mov    al,thin_bit        ; Thick or thin cable bit
  176.     out    dx,al            ; Turn off board reset bit
  177.     call    do_reset
  178.     loadport
  179.     endm
  180.  
  181. terminate_board    macro
  182.     endm
  183.  
  184. ; The following three values may be overridden from the command line.
  185. ; If they are omitted from the command line, these defaults are used.
  186. ; The shared memory base is set by a jumper.  We read it from the
  187. ; card and set up accordingly.
  188.  
  189.     public    int_no, io_addr, thin_not_thick
  190. int_no        db    2,0,0,0        ; Interrupt level
  191. io_addr        dw    0300h,0        ; I/O address for card (jumpers)
  192. thin_not_thick    dw    1,0        ; Non-zero means thin net
  193.     public    mem_base
  194. mem_base    dw    00000h,0    ; Shared memory addr (jumpers)
  195. ; (Not changeable by software in 3C503)    ; (0 if disabled by jumpers)
  196. thin_bit    db    ECNTRL_THIN    ; Default to thin cable
  197.  
  198.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  199. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  200. driver_type    db    12        ;from the packet spec
  201. driver_name    db    '3C503',0    ;name of the driver.
  202. driver_function    db    2
  203. parameter_list    label    byte
  204.     db    1    ;major rev of packet driver
  205.     db    9    ;minor rev of packet driver
  206.     db    14    ;length of parameter list
  207.     db    EADDR_LEN    ;length of MAC-layer address
  208.     dw    GIANT    ;MTU, including MAC headers
  209.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  210.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  211.     dw    0    ;(# of successive xmits) - 1
  212. int_num    dw    0    ;Interrupt # to hook for post-EOI
  213.             ;processing, 0 == none,
  214.  
  215. is_186        db    0
  216.  
  217.     include    movemem.asm
  218.  
  219. block_output:
  220. ;enter with cx = byte count, ds:si = buffer location, ax = buffer address
  221.     assume    ds:nothing
  222.     cmp    mem_base,0        ;memory or I/O?
  223.     je    block_o            ;I/O.
  224.     mov    es,mem_base        ; Set up ES:DI at the shared RAM
  225.     mov    di,ax            ; ..
  226.     loadport            ; Set up for address of TX buffer.
  227.     ram_enable            ; Make sure the RAM is actually there.
  228.     call    movemem
  229.     clc
  230.     ret
  231.  
  232. block_o:
  233.     loadport
  234.     setport    E33G_DMAAL
  235.     out    dx,al
  236.     setport    E33G_DMAAH
  237.         mov     al,ah
  238.         out     dx,al
  239.  
  240.     setport    E33G_CNTRL
  241.     mov    al,thin_bit
  242.     or    al,ECNTRL_OUTPUT or ECNTRL_START ;start dma, write to board.
  243.     out    dx,al
  244.  
  245.     cmp    is_186,0
  246.     je    block_o_88
  247.  
  248.     .286
  249.     setport    E33G_STATUS
  250. block_o_186_0:
  251.     jcxz    block_o_2        ;if there is none, exit.
  252.     in    al,dx            ;wait for the FIFO to be ready.
  253.     test    al,ESTAT_DPRDY
  254.     je    block_o_186_0
  255.     setport    E33G_FIFOH        ;now get ready to read data.
  256.     cmp    cx,8            ;do we have eight more to do?
  257.     jb    block_o_186_1        ;no, do them one by one.
  258.     outsw                ;yes, output eight all at once.
  259.     outsw
  260.     outsw
  261.     outsw
  262.     sub    cx,8            ;reduce the count by what we write.
  263.     setport    E33G_STATUS        ;go back to the status bit.
  264.     jmp    block_o_186_0
  265. block_o_186_1:
  266.     rep    outsb            ;output less than 8 bytes.
  267.     jmp    short block_o_2
  268.     .8086
  269.  
  270.  
  271. block_o_88:
  272.     loadport
  273.     setport    E33G_STATUS
  274. block_o_88_0:
  275.     jcxz    block_o_2        ;if there is none, exit.
  276.     in    al,dx            ;wait for the FIFO to be ready.
  277.     test    al,ESTAT_DPRDY
  278.     je    block_o_88_0
  279.     setport    E33G_FIFOH        ;now get ready to read data.
  280.     cmp    cx,8            ;do we have eight more to do?
  281.     jb    block_o_88_1        ;no, do them one by one.
  282.     lodsw                ;yes, output eight all at once.
  283.     out    dx,ax
  284.     lodsw
  285.     out    dx,ax
  286.     lodsw
  287.     out    dx,ax
  288.     lodsw
  289.     out    dx,ax
  290.     sub    cx,8            ;reduce the count by what we write.
  291.     setport    E33G_STATUS        ;go back to the status bit.
  292.     jmp    block_o_88_0
  293. block_o_88_1:
  294.     lodsb                ;output less than 8 bytes.
  295.     out    dx,al
  296.     loop    block_o_88_1
  297. block_o_2:
  298.     loadport
  299.     setport    E33G_CNTRL
  300.     mov    al,thin_bit        ;stop dma.
  301.     out    dx,al
  302.     ret
  303.  
  304.  
  305. block_input:
  306. ;enter with cx = byte count, es:di = buffer location, ax = board address.
  307.     cmp    mem_base,0        ; memory or I/O
  308.     je    block_i            ; I/O
  309.     push    ds
  310.     assume    ds:nothing
  311.     mov    ds,mem_base        ; ds:si points at first byte to move
  312.     mov    si,ax
  313.  
  314.     add    ax,cx            ; Find the end of this frame.
  315.     cmp    ah,byte ptr cs:sm_rstop_ptr ; Over the top of the ring?
  316.     jb    rcopy_one_piece        ; Go move it
  317.  
  318. rcopy_wrap:
  319. ; Copy in two pieces due to buffer wraparound.
  320.     mov    ah,byte ptr cs:sm_rstop_ptr ; Compute length of first part
  321.     xor    al,al
  322.     sub    ax,si            ;  as all of the pages up to wrap point
  323.     sub    cx,ax            ; Move the rest in second part
  324.     push    cx            ; Save count of second part
  325.     mov    cx,ax            ; Count for first move
  326.     call    rcopy_subr
  327.     mov    si,SM_RSTART_PG*256    ; Offset to start of first receive page
  328.     pop    cx            ; Bytes left to move
  329. rcopy_one_piece:
  330.     call    rcopy_subr
  331.     pop    ds
  332.     ret
  333.  
  334.  
  335. rcopy_subr:
  336.     shr    cx,1            ; convert byte count to word count
  337.     rep    movsw
  338.     jnc    rcv_wrap_even        ; odd byte left over?
  339.     lodsw                ;   yes, word fetch
  340.     stosb                ;   and byte store
  341. rcv_wrap_even:
  342.     ret
  343.  
  344. block_i:
  345.     assume    ds:code
  346.     loadport
  347.     setport    E33G_DMAAL
  348.     out    dx,al
  349.     setport    E33G_DMAAH
  350.         mov     al,ah
  351.         out     dx,al
  352.  
  353.     setport    E33G_CNTRL
  354.     mov    al,thin_bit
  355.     or    al,ECNTRL_INPUT or ECNTRL_START ;start dma, read from board.
  356.     out    dx,al
  357.  
  358.     cmp    is_186,0
  359.     je    block_i_88
  360.  
  361.     .286
  362.     setport    E33G_STATUS
  363. block_i_186_0:
  364.     jcxz    block_i_2        ;if there is none, exit.
  365.     in    al,dx            ;wait for the FIFO to be ready.
  366.     test    al,ESTAT_DPRDY
  367.     je    block_i_186_0
  368.     setport    E33G_FIFOH        ;now get ready to read data.
  369.     cmp    cx,8            ;do we have eight more to do?
  370.     jb    block_i_186_1        ;no, do them one by one.
  371.     insw                ;yes, input eight all at once.
  372.     insw
  373.     insw
  374.     insw
  375.     sub    cx,8            ;reduce the count by what we read.
  376.     setport    E33G_STATUS        ;go back to the status bit.
  377.     jmp    block_i_186_0
  378. block_i_186_1:
  379.     rep    insb            ;input less than 8 bytes.
  380.     jmp    short block_i_2
  381.     .8086
  382.  
  383.  
  384. block_i_88:
  385.     loadport
  386.     setport    E33G_STATUS
  387. block_i_88_0:
  388.     jcxz    block_i_2        ;if there is none, exit.
  389.     in    al,dx            ;wait for the FIFO to be ready.
  390.     test    al,ESTAT_DPRDY
  391.     je    block_i_88_0
  392.     setport    E33G_FIFOH        ;now get ready to read data.
  393.     cmp    cx,8            ;do we have eight more to do?
  394.     jb    block_i_88_1        ;no, do them one by one.
  395.     in    ax,dx            ;yes, input eight all at once.
  396.     stosw
  397.     in    ax,dx
  398.     stosw
  399.     in    ax,dx
  400.     stosw
  401.     in    ax,dx
  402.     stosw
  403.     sub    cx,8            ;reduce the count by what we write.
  404.     setport    E33G_STATUS        ;go back to the status bit.
  405.     jmp    block_i_88_0
  406. block_i_88_1:
  407.     in    al,dx            ;input less than 8 bytes.
  408.     stosb
  409.     loop    block_i_88_1
  410. block_i_2:
  411.     loadport
  412.     setport    E33G_CNTRL
  413.     mov    al,thin_bit        ;stop dma.
  414.     out    dx,al
  415.     ret
  416.  
  417.  
  418.  
  419.     include    8390.asm
  420.  
  421.     public    usage_msg
  422. usage_msg    db    "usage: 3C503 [-n] [-d] [-w] <packet_int_no> <int_level(2-5)> <io_addr> <thin_net_flag>",CR,LF,'$'
  423.  
  424.     public    copyright_msg
  425. copyright_msg    db    "Packet driver for 3-Com 3C503, version "
  426.         db    '0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+dp8390_version,CR,LF
  427.         db    "Portions Copyright 1989, Robert C. Clements, K1BC",CR,LF,'$'
  428.  
  429. cfg_err_msg    db    "3C503 Configuration failed. Check parameters.",CR,LF,'$'
  430. mem_busted_msg    db    "Shared RAM on 3C503 card is defective or there is an address conflict.",CR,LF,'$'
  431.  
  432. int_no_name    db    "Interrupt number ",'$'
  433. io_addr_name    db    "I/O port ",'$'
  434. mem_base_name    db    "Memory address ",'$'
  435.  
  436. thin_msg    db    "Using the built-in transceiver (thinwire)",CR,LF,'$'
  437. thick_msg    db    "Using the external transceiver (thickwire)",CR,LF,'$'
  438.  
  439.  
  440.     extrn    set_recv_isr: near
  441.  
  442. ;enter with si -> argument string, di -> word to store.
  443. ;if there is no number, don't change the number.
  444.     extrn    get_number: near
  445.  
  446. ;enter with dx -> name of word, di -> dword to print.
  447.     extrn    print_number: near
  448.  
  449.     public    parse_args
  450. parse_args:
  451. ;exit with nc if all went well, cy otherwise.
  452.     mov    di,offset int_no    ; May override interrupt channel
  453.     call    get_number
  454.     mov    di,offset io_addr    ; May override I/O address
  455.     call    get_number
  456.     mov    di,offset thin_not_thick    ; May override thick/thin cable flag
  457.     call    get_number
  458.     mov    ax,thin_not_thick    ; Now make the right bit
  459.     cmp    ax,0
  460.     je    parse_thin1        ; If zero, leave bit off
  461.     mov    al,ECNTRL_THIN        ; Else the bit for the card
  462. parse_thin1:
  463.     mov    thin_bit,al        ; Save for setting up the card
  464.  
  465.     clc
  466.     ret
  467.  
  468. do_reset:
  469.     assume    ds:code
  470.     loadport
  471.     cli                ; Protect the E33G_CNTRL contents
  472.     setport E33G_CNTRL        ; Switch control bits to enable SA PROM
  473.     mov al,    thin_bit
  474.     or al,    ECNTRL_SAPROM
  475.     out dx,    al            ; ..
  476.     setport    E33_SAPROM        ; Where the address prom is
  477.  
  478.     cld                ; Make sure string mode is right
  479.     push    cs            ; Point es:di at local copy space
  480.     pop    es
  481.     mov di,    offset curr_hw_addr
  482.     mov cx,    EADDR_LEN        ; Set count for loop
  483. do_reset_1:
  484.     in al,    dx            ; Get a byte of address
  485.     stosb                ; Feed it to caller
  486.     inc    dx            ; Next byte at next I/O port
  487.     loop    do_reset_1        ; Loop over six bytes
  488.  
  489.     loadport            ; Re-establish I/O base after dx mods
  490.     setport E33G_CNTRL        ; Switch control bits to turn off SA PROM
  491.     mov al,    thin_bit
  492.     out dx,    al            ; Turn off SA PROM windowing
  493.     sti                ; Ok for E33G_CNTRL to change now
  494.  
  495.     call    set_8390_eaddr
  496.  
  497.     ret
  498.  
  499. init_card:
  500. ; Now get the board's physical address from on-board PROM into card_hw_addr
  501.     assume    ds:code
  502.     loadport
  503.     cli                ; Protect the E33G_CNTRL contents
  504.     setport E33G_CNTRL        ; Switch control bits to enable SA PROM
  505.     mov al,    thin_bit
  506.     or al,    ECNTRL_SAPROM
  507.     out dx,    al            ; ..
  508.     setport    E33_SAPROM        ; Where the address prom is
  509.  
  510.     cld                ; Make sure string mode is right
  511.     push    cs            ; Point es:di at local copy space
  512.     pop    es
  513.     mov di,    offset curr_hw_addr
  514.     mov cx,    EADDR_LEN        ; Set count for loop
  515. ini_addr_loop:
  516.     in al,    dx            ; Get a byte of address
  517.     stosb                ; Feed it to caller
  518.     inc    dx            ; Next byte at next I/O port
  519.     loop    ini_addr_loop        ; Loop over six bytes
  520.  
  521.     loadport            ; Re-establish I/O base after dx mods
  522.     setport E33G_CNTRL        ; Switch control bits to turn off SA PROM
  523.     mov al,    thin_bit
  524.     out dx,    al            ; Turn off SA PROM windowing
  525.     sti                ; Ok for E33G_CNTRL to change now
  526. ; Point the "Vector Pointer" registers off into the boonies so we
  527. ; don't get the shared RAM disabled on us while we're using it.
  528. ; Ideally a warm boot should reset this too, to get to ROM on this card,
  529. ; but I don't know a guaranteed way to determine that value.
  530.     setport    E33G_VP2
  531.     mov al,    0ffh            ; Point this at the ROM restart location
  532.     out dx,    al            ;  of ffff0h.
  533.     setport E33G_VP1
  534.     out dx,    al
  535.     xor al,    al
  536.     setport E33G_VP0
  537.     out dx,    al
  538. ;Make sure shared memory is jumpered on. Find its address.
  539.     setport E33G_ROMBASE        ; Point at rom/ram cfg reg
  540.     xor    bx,bx
  541.     in al,    dx            ; Read it
  542.     test al,0f0h            ; Any bits on?
  543.     je    memcfg_3        ; no - using I/O.
  544. memcfg_1:
  545.     mov bx,    0c600h            ; Build mem segment here
  546.     test al,0c0h            ; DC00 or D800?
  547.     je    memcfg_2        ; No
  548.     add bx,    01000h            ; Yes, make Dx00
  549. memcfg_2:
  550.     test al,0a0h            ; DC00 or CC00?
  551.     je    memcfg_3
  552.     add bx,    00400h            ; Yes, make xC00
  553. memcfg_3:
  554.     mov mem_base,bx            ; Remember segment addr of memory
  555.     or    bx,bx
  556.     je    mem_works        ; don't test the memory if we use I/O.
  557. ; Set up Gate Array's Config Reg to enable and size the RAM.
  558.     setport    E33G_GACFR        ; Make sure gate array is set up and
  559.     mov al,    EGACFR_IRQOFF        ;  the RAM is enabled (not EPROM)
  560.     out dx,    al            ; ..
  561. ; Check the card's memory
  562.     mov ax,    mem_base        ; Set segment of the shared memory
  563.     add ax,    16*SM_TSTART_PG        ;  which starts 2000h up from "base"
  564.     mov cx,    2000h            ; Length of RAM to test
  565.     call    memory_test        ; Check it out
  566.     jz    mem_works        ; Go if it's OK
  567.     jmp    mem_busted        ; Go report failure if it's bad
  568. mem_works:
  569. ; Set up control of shared memory, buffer ring, etc.
  570.     loadport
  571.     setport    E33G_STARTPG        ; Set ASIC copy of rx's first buffer page
  572.     mov al,    SM_RSTART_PG
  573.     out dx,    al
  574.     setport    E33G_STOPPG        ;  and ASIC copy of rx's last buffer page + 1
  575.     mov al,SM_RSTOP_PG
  576. ;    mov al,    byte ptr sm_rstop_ptr
  577.     out dx,    al
  578. ; Set up interrupt/DMA control register in ASIC.
  579. ; For now, we won't use the DMA, so B0-B3 are zero.
  580.     xor ah,    ah            ; Get the interrupt level from arg line
  581.     mov al,    int_no            ; ..
  582.     cmp al,    9            ; If converted to 9, make back into 2
  583.     jne    get_irq1        ; Not 9
  584.     mov al,    2            ; Card thinks it's IRQ2
  585. get_irq1:                ; Now should have level in range 2-5
  586.     sub ax,    2            ; Make 0-3 for tables
  587.     cmp ax,    5-2            ; In range?
  588.     jna    get_irq2
  589.     mov    dx,offset cfg_err_msg
  590.     jmp    error            ; If not, can't configure.
  591. get_irq2:
  592.     xor cx,    cx            ; Make the bit for the ASIC
  593.     mov cl,    al            ; Shift count
  594.     mov al,    10h            ; Bit for irq2
  595.     shl al,    cl            ; Shift over as needed.
  596.     setport    E33G_IDCFR        ; Point at ASIC reg for IRQ level
  597.     out dx,    al            ; Set the bit
  598.     setport    E33G_NBURST        ; Set burst size to 8
  599.     mov al,    8
  600.     out dx,    al            ; ..
  601.     setport    E33G_DMAAH        ; Set up transmit bfr in DMA addr
  602.     mov al,    SM_TSTART_PG
  603.     out dx,    al
  604.     xor ax,    ax
  605.     setport E33G_DMAAL
  606.     out dx,    al
  607.     ret
  608.  
  609.  
  610. mem_busted:
  611.     mov dx,    offset mem_busted_msg
  612. error:
  613.     mov    ah,9        ; Type the msg
  614.     int    21h
  615.     stc            ; Indicate error
  616.     ret            ; Return to common code
  617.  
  618.  
  619.     public    print_parameters
  620. print_parameters:
  621.     mov di,    offset int_no        ; May override interrupt channel
  622.     mov dx,    offset int_no_name    ; Message for it
  623.     call    print_number
  624.     mov di,    offset io_addr        ; May override I/O address
  625.     mov dx,    offset io_addr_name    ; Message for it
  626.     call    print_number
  627.     mov    dx,offset thin_msg
  628.     cmp    thin_not_thick,0        ; May override thick/thin cable flag
  629.     jne    print_parameters_1
  630.     mov    dx,offset thick_msg
  631. print_parameters_1:
  632.     mov    ah,9
  633.     int    21h
  634.     ret
  635.  
  636.     include memtest.asm
  637.  
  638. code    ends
  639.  
  640.     end
  641.